package com.my.entity;

import java.util.List;

public class Page {
    private int currentPage;
    private int pageSize;
    private int totalCount;
    private int totalPage;
    private List<User> users;

    public Page(){}

    public Page(int currentPage, int pageSize, int totalCount, int totalPage, List<User> users) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.totalPage = totalPage;
        this.users = users;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        if(currentPage<1){
            this.currentPage = 1;
        }else if(currentPage>totalPage){
            this.currentPage = totalPage;
        }else{
            this.currentPage = currentPage;
        }
        //System.out.println(currentPage + "---" + this.currentPage);
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
        this.totalPage = this.totalCount%this.pageSize==0 ? this.totalCount/this.pageSize : this.totalCount/this.pageSize+1;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public List<User> getUsers() {
        return users;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }
}
